import os, time
from multiprocessing import Pool


# 实现文件的拷贝
def copyFile(rPath, wPaht):
    fr = open(rPath, "rb")
    fw = open(wPaht, "wb")

    context = fr.read()
    fw.write(context)
    fr.close()
    fw.close()


path = r"F:\file"
topath = r"F:\tofile"

if __name__ == "__main__":
    # 读取path下的所有的文件
    filesList = os.listdir(path)

    start = time.time()
    pp = Pool()
    for fileName in filesList:
        pp.apply_async(copyFile, args=(os.path.join(path, fileName), os.path.join(topath, fileName)))

    pp.close()
    pp.join()
    end = time.time()
    print("总耗时： %0.2f" % (end - start))
